#include<stdio.h>
#include<string.h>

int main()
{
    char str[1001] = { 0 };
    fgets(str, sizeof(str), stdin);
    int len = strlen(str);
    int count = 0;
    for (int i = 0; i < len - 1; i++)
    {
        if (str[i] - '0' != 6)
        {
            if (count == 3)
                printf("%s", "666");
            printf("%c", str[i]);
            count = 0;
        }
        else
        {
            count++;
            if (count > 3 && count < 9 && str[i + 1] - '0' != 6)
                printf("%c", '9');
            if (count >= 9 && count < 18 && str[i + 1] - '0' != 6)
                printf("%s", "27");

        }
    }
    return 0;
}